package com.vitogiovanni.tobook.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.vitogiovanni.tobook.entity.Gestore;
import com.vitogiovanni.tobook.entity.GestoreEndpoint;

/**
 * Servlet implementation class InvitaLavoroServlet
 */
public class InserisciGestoreServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public InserisciGestoreServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
				
	}
	
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		Gestore gestore = new Gestore();
		GestoreEndpoint gestoreEndpoint = new GestoreEndpoint();
		
		String nome = req.getParameter("nome");
		String cognome = req.getParameter("cognome");
		String email = req.getParameter("email");
		String password = req.getParameter("password");
	
		gestore.setNome(nome);
		gestore.setCognome(cognome);
		gestore.setEmail(email);
		gestore.setPassword(password);
		
		gestoreEndpoint.insertGestore(gestore);
		
		resp.sendRedirect("/inserimento.html");
	}
}